import request from '@/utils/request';

/**
 *    房东API
 */
export default {
	// 获取忘记密码验证码
	getLandlordForgetPassCode(email) {
		return request('/landlord/forgetPassCode', { email }, 'get');
	},
	// 忘记密码
	landlordForgetPass(data) {
		return request('/landlord/forgetPass', data, 'post');
	},

	//修改密码
	modifyPass(data) {
		return request('/landlord/modifyPass', data, 'post');
	},

	//查看个人信息
	getLandlordInfo() {
		return request('/landlord/userInfo', {}, 'get');
	},

	//修改个人信息
	updateUserInfo(data) {
		return request('/landlord/updateInfo', data, 'post');
	},

	//上传头像
	uploadLogo(data) {
		return request('/landlord/uploadLogo', data, 'post', {
			headers: {
				'Content-Type': 'multipart/form-data'
			}
		});
	},

	//获取修改邮箱验证码
	getModifyEmailCode(email) {
		return request('/landlord/getUpdateEmailCode', { email }, 'get');
	},

	//修改邮箱
	updateEmail(data) {
		return request('/landlord/updateEmail', data, 'post');
	},

	// 根据房源id查询房东信息
	getLandlordInfoByHouseId(houseId) {
		return request(`/landlord/getLandlordByHouseId/${houseId}`, {}, 'get');
	},

	//发送消息
	sendMessage(data) {
		return request('/chat/send', data, 'post');
	},

	//获取该用户的所有会话
	getAllConversations(landlordId) {
		return request(`/chat/landlord/allConversations/${landlordId}`, {}, 'get');
	},

	//获取会话中所有的消息
	getAllMessages(conversationId) {
		return request(`/chat/messages/${conversationId}`, {}, 'get');
	},

	// 标记该会话中的消息为已读
	markMessagesAsRead(conversationId, viewerId) {
		return request(`/chat/markAsRead/${conversationId}/${viewerId}`, {}, 'put');
	},

	//通过id获取房源信息---房东端
	getHouseByIdLandlord(houseId) {
		return request(`/landlord/getHouseById/${houseId}`, {}, 'get');
	},

	//上传房源图片
	uploadHouseImg(data) {
		return request('/landlord/uploadImage', data, 'post', {
			headers: {
				'Content-Type': 'multipart/form-data'
			}
		});
	},

	//上传产权证明
	uploadTitleDeed(data) {
		return request('/landlord/uploadTitleDeed', data, 'post', {
			headers: {
				'Content-Type': 'multipart/form-data'
			}
		});
	},

	//上传房源信息
	uploadHouse(data) {
		return request('/landlord/uploadHouse', data, 'post');
	},

	//获取我的房源
	getMyHouse(pageNo, pageSize, status) {
		return request(`/landlord/myHouses/${pageNo}/${pageSize}/${status}`, {}, 'get');
	},

	//修改房源
	updateHouse(data) {
		return request('/landlord/updateHouse', data, 'post');
	},

	//更新房源状态
	updateHouseStatus(data) {
		return request('/landlord/updateHouseStatus', data , 'post');
	},

	//获取预约列表
	getAllAppointments(pageNo, pageSize) {
		return request(`/landlord/allAppointments/${pageNo}/${pageSize}`, {}, 'get');
	},

	//审核预约
	auditAppointment(data) {
		return request('/landlord/auditAppointment', data, 'post');
	},

	//获取房东档期
	getLandlordAllSchedules(isFuture) {
		return request('/landlord/myAllSchedules', { isFuture }, 'get');
	},

	//修改档期
	updateSchedule(data) {
		return request('/landlord/updateSchedule', data, 'post');
	},
};
